import Vue from 'vue'
import Router from "./router";

// 路由守卫
Router.beforeEach((to, from, next) => {
  const token = localStorage.getItem('token');
  if (token) {
    if (to.path == "/login") {
      next(from.path);
      Vue.prototype.$Message.warning('请勿重复登录')
    } else {
      next();
    }
  } else {
    if (to.path == "/login") {
      next();
    } else {
      Vue.prototype.$Message.warning("请先登录");
      next("/login");
    }
  }
});